home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / moonstonemadness.swf / scripts / __Packages / BaseLevelData.as next >
Text File  |  2007-09-27  |  6KB  |  172 lines

  1. class BaseLevelData
  2. {
  3.    static var SECONDS = 1000;
  4.    static var MINUTES = 60 * BaseLevelData.SECONDS;
  5.    static var STATUS_COMPLETED = 1;
  6.    static var STATUS_INCOMPLETE = 2;
  7.    static var LEVEL_TYPE_STORY = 1;
  8.    static var LEVEL_TYPE_USER = 2;
  9.    static var POINTS_BASE = 50000;
  10.    static var POINTS_PER_MS_BASE = 750;
  11.    static var POINTS_PER_MS_OVER = 1500;
  12.    static var POINTS_PER_MINISTONES = 100;
  13.    static var POINTS_PER_MILLISECOND_REMAINING = 1.25;
  14.    function BaseLevelData()
  15.    {
  16.       this.aPanels = new Array();
  17.       this.aPanelBg2 = new Array();
  18.       this.nRequiredMS = 0;
  19.       this.nCollectedMS = 0;
  20.       this.nMiniStones = 0;
  21.       this.nTimeTaken = 0;
  22.       this.bCompleted = false;
  23.       this.bLocked = true;
  24.    }
  25.    function onInit()
  26.    {
  27.       var _loc2_ = SharedObject.getLocal(PlayerStatus.SAVE_SO_NAME);
  28.       if(_loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber] != undefined)
  29.       {
  30.          this.bCompleted = _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].bCompleted;
  31.          this.bLocked = _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].bLocked;
  32.          this.nCollectedMS = _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].nCollectedMS;
  33.          this.nMiniStones = _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].nMiniStones;
  34.          this.nTimeTaken = _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].nTimeTaken;
  35.       }
  36.       false;
  37.    }
  38.    function doSave()
  39.    {
  40.       var _loc2_ = SharedObject.getLocal(PlayerStatus.SAVE_SO_NAME);
  41.       _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber] = new Object();
  42.       _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].bCompleted = this.bCompleted;
  43.       _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].bLocked = this.bLocked;
  44.       _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].nCollectedMS = this.nCollectedMS;
  45.       _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].nMiniStones = this.nMiniStones;
  46.       _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].nTimeTaken = this.nTimeTaken;
  47.       if(this.nLevelType == BaseLevelData.LEVEL_TYPE_USER)
  48.       {
  49.          _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].nLevelNumber = this.nLevelNumber;
  50.          _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].sLevelName = this.sLevelName;
  51.          _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].nTimeAllowed = this.nTimeAllowed;
  52.          _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].nRequiredMS = this.nRequiredMS;
  53.          _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber].aPanels = this.aPanels;
  54.       }
  55.       _loc2_.flush();
  56.       false;
  57.    }
  58.    function doDeleteFromSave()
  59.    {
  60.       var _loc2_ = SharedObject.getLocal(PlayerStatus.SAVE_SO_NAME);
  61.       delete _loc2_.data["LevelType" + this.nLevelType + "_LevelNumber" + this.nLevelNumber];
  62.       _loc2_.flush();
  63.       false;
  64.    }
  65.    function set LevelNumber(__nLevelNumber)
  66.    {
  67.       this.nLevelNumber = __nLevelNumber;
  68.    }
  69.    function get LevelNumber()
  70.    {
  71.       return this.nLevelNumber;
  72.    }
  73.    function set LevelName(__sLevelName)
  74.    {
  75.       this.sLevelName = __sLevelName;
  76.    }
  77.    function get LevelName()
  78.    {
  79.       var _loc2_ = this.sLevelName;
  80.       if(_loc2_ == undefined || _loc2_ == "")
  81.       {
  82.          _loc2_ = "Game " + this.__get__LevelNumber();
  83.       }
  84.       return _loc2_;
  85.    }
  86.    function get Locked()
  87.    {
  88.       return this.bLocked;
  89.    }
  90.    function set Locked(__bLocked)
  91.    {
  92.       this.bLocked = __bLocked;
  93.    }
  94.    function get Completed()
  95.    {
  96.       return this.bCompleted;
  97.    }
  98.    function set Completed(__bCompleted)
  99.    {
  100.       this.bCompleted = __bCompleted;
  101.    }
  102.    function set LevelType(__nLevelType)
  103.    {
  104.       this.nLevelType = __nLevelType;
  105.    }
  106.    function get LevelType()
  107.    {
  108.       return this.nLevelType;
  109.    }
  110.    function get Panels()
  111.    {
  112.       return this.aPanels;
  113.    }
  114.    function set RequiredMS(__nRequiredMS)
  115.    {
  116.       this.nRequiredMS = __nRequiredMS;
  117.    }
  118.    function get RequiredMS()
  119.    {
  120.       return this.nRequiredMS;
  121.    }
  122.    function set CollectedMS(__nCollectedMS)
  123.    {
  124.       this.nCollectedMS = __nCollectedMS;
  125.    }
  126.    function get CollectedMS()
  127.    {
  128.       return this.nCollectedMS;
  129.    }
  130.    function set TimeAllowed(__nTimeAllowed)
  131.    {
  132.       this.nTimeAllowed = __nTimeAllowed;
  133.    }
  134.    function get TimeAllowed()
  135.    {
  136.       return this.nTimeAllowed;
  137.    }
  138.    function set TimeTaken(__nTimeTaken)
  139.    {
  140.       this.nTimeTaken = __nTimeTaken;
  141.    }
  142.    function get TimeTaken()
  143.    {
  144.       return this.nTimeTaken;
  145.    }
  146.    function set MiniStones(__nMiniStones)
  147.    {
  148.       this.nMiniStones = __nMiniStones;
  149.    }
  150.    function get MiniStones()
  151.    {
  152.       return this.nMiniStones;
  153.    }
  154.    function get Score()
  155.    {
  156.       return this.getScore();
  157.    }
  158.    function getScore()
  159.    {
  160.       var _loc2_ = 0;
  161.       if(this.__get__Completed())
  162.       {
  163.          _loc2_ += BaseLevelData.POINTS_BASE;
  164.          _loc2_ += Math.min(this.__get__CollectedMS(),this.__get__RequiredMS()) * BaseLevelData.POINTS_PER_MS_BASE;
  165.          _loc2_ += Math.max(this.__get__CollectedMS() - this.__get__RequiredMS(),0) * BaseLevelData.POINTS_PER_MS_OVER;
  166.          _loc2_ += Math.floor((this.__get__TimeAllowed() - this.__get__TimeTaken()) * BaseLevelData.POINTS_PER_MILLISECOND_REMAINING);
  167.          _loc2_ += this.__get__MiniStones() * BaseLevelData.POINTS_PER_MINISTONES;
  168.       }
  169.       return _loc2_;
  170.    }
  171. }
  172.